//
//  WSAlbumsSectionHeadView.m
//  GroupFourFM
//
//  Created by dllo on 15/12/25.
//  Copyright © 2015年 GroupFour. All rights reserved.
//

#import "WSAlbumsSectionHeadView.h"

@interface WSAlbumsSectionHeadView ()

@property (nonatomic, strong) WSBaseCollectionLabel *myLabel;

@end

@implementation WSAlbumsSectionHeadView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = WHITE;
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews {
    
    self.myLabel = [[WSBaseCollectionLabel alloc] init];
    self.myLabel.backgroundColor = CLEAR;
    self.myLabel.textColor = [UIColor colorWithRed:0.54 green:0.54 blue:0.54 alpha:1];
    self.myLabel.font = [UIFont systemFontOfSize:15];
    self.myLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.myLabel];
    [self.myLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.top.left.mas_equalTo(@0);
        make.width.mas_equalTo(100);
    }];
    
    UIButton *sortButton = [UIButton buttonWithType:UIButtonTypeCustom];
    sortButton.backgroundColor = CLEAR;
    [sortButton setTitle:@"排序" forState:UIControlStateNormal];
    sortButton.titleLabel.font = [UIFont systemFontOfSize:17 weight:0];
    [sortButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [sortButton addTarget:self action:@selector(sortAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:sortButton];
    [sortButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.top.right.mas_equalTo(@0);
        make.width.mas_equalTo(100);
    }];
}

- (void)setNum:(NSInteger)num {

    _num = num;
    self.myLabel.text = [NSString stringWithFormat:@"共 %ld 集", num];
}

- (void)sortAction:(UIButton *)button {

    [self.delegate sortListWithButton:button];
}

@end
